package com.lfg.leetcode.leetcode100;

import java.util.ArrayList;
import java.util.List;

public class No119getRow {

    public static void main(String[] args) {
        System.out.println("[" + getRow(3) + "]");
    }


    public static List<Integer> getRow(int rowIndex) {
        List<Integer> ret = new ArrayList<>(1);
        ret.add(1);
        for (int i = 1; i <= rowIndex; i++) {
            List<Integer> data = ret;
            List<Integer> l = new ArrayList<>(data.size() + 1);
            for (int j = 0; j <= i; j++) {
                int num = 0;
                int left = j - 1;
                if (left >= 0) {
                    num = data.get(left);
                }
                if (j < data.size()) {
                    num += data.get(j);
                }
                l.add(num);
            }
            ret = l;
        }
        return ret;
    }
}
